package test;

import javassist.SerialVersionUID;

import java.io.*;

public class SerializeTest2 implements Serializable {
    int a = 99;
    int b = 88;
    private static final long serialVersionUID = 3L;


    public static void main(String[] args) throws Exception {
        //write(new SerializeTest2());
        read();
    }

    public SerializeTest2(){
        System.out.println("cons");
    }

    public static void write(Object o) throws Exception {
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("c:/a.ser"));
        out.writeObject(o);
        out.close();
    }

    public static void read() throws Exception {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("c:/a.ser"));
        System.out.println(in.readObject());
        in.close();
    }

    @Override
    public String toString() {
        return "SerializeTest2{" +
                "a=" + a +
                ", b=" + b +
                '}';
    }

    //
    private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
        System.out.println("SerializeTest2 readObject");
        in.defaultReadObject();
    }

    private void writeObject(ObjectOutputStream out) throws IOException {
        System.out.println("SerializeTest2 writeObject");
        out.defaultWriteObject();

    }
}
